package com.prs.crm.action.sys;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;

import com.prs.crm.domain.sys.RemindInfoSendSet;
import com.prs.crm.service.sys.RemindInfoSendSetService;

public class RemindInfoSendSetAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private RemindInfoSendSet remindInfoSendSet;
	private RemindInfoSendSetService remindInfoSendSetService;
	private String serCode;
	public String getSerCode() {
		return serCode;
	}
	public void setSerCode(String serCode) {
		this.serCode = serCode;
	}
	public RemindInfoSendSet getRemindInfoSendSet() {
		return remindInfoSendSet;
	}
	public void setRemindInfoSendSet(RemindInfoSendSet remindInfoSendSet) {
		this.remindInfoSendSet = remindInfoSendSet;
	}
	public RemindInfoSendSetService getRemindInfoSendSetService() {
		return remindInfoSendSetService;
	}
	public void setRemindInfoSendSetService(
			RemindInfoSendSetService remindInfoSendSetService) {
		this.remindInfoSendSetService = remindInfoSendSetService;
	}
	
	@Action("editRemindInfoSendSet")
	public String editRemindInfoSendSet(){
		this.remindInfoSendSet=this.getRemindInfoSendSetService().getRemindInfoSendSet(serCode);
		return SUCCESS;
	}
	@Action(value="saveRemindInfoSendSet",results={
			@Result(name="success",type="redirect",location="editRemindInfoSendSet?serCode=${remindInfoSendSet.getType()}"),
			@Result(name="error",type="chain",location="editRemindInfoSendSet?serCode=${remindInfoSendSet.getType()}")
	})
	public String saveRemindInfoSendSet(){
		RemindInfoSendSet remind=this.getRemindInfoSendSetService().getRemindInfoSendSet("rs01");
		if (remind==null) {
			remind=new RemindInfoSendSet();
			remind.setType("rs01");
			remind.setAppEmail(remindInfoSendSet.getAppEmail());
			remind.setAppMobile(remindInfoSendSet.getAppMobile());
			remind.setAppSys(remindInfoSendSet.getAppSys());
			remind.setSchedulEmail(remindInfoSendSet.getSchedulEmail());
			remind.setScheduleSys(remindInfoSendSet.getScheduleSys());
			remind.setScheduleMobile(remindInfoSendSet.getScheduleMobile());
			this.getRemindInfoSendSetService().save(remind);
		}else{
			this.getRemindInfoSendSetService().submit(remind);
		}
		remindInfoSendSet=remind;
		return SUCCESS;
	}
}
